namespace game {
    export namespace gameData {

        export class GameDataModule extends mvc.Module {

            constructor() {
                super(GameDataModule.NAME);
            }

            public listNotificationInterests(): string[] {
                return [common.Command.INIT_MODULE];
            }

            public handleNotification(note: mvc.Notification): void {
                switch (note.name) {
                    case common.Command.INIT_MODULE: //初始化模块
                        this.InitGameData();
                        break;
                }
            }

            public InitGameData() {
                lib.ObjectValue.save = this.save;
                lib.ObjectValue.read = this.read;
                lib.Binding.addBindingCheck(game);
                game.data = lib.DataManager.createData("game.gameData.Main");
                lib.Binding.addBindingCheck(game.data);
                game.data.checkAllBinding();
            }


            save(type: string, name: string, value: any) {
                if (type) {
                    cc.sys.localStorage.setItem(name, value);
                }
            }

            read(type: string, name: string): any {
                if (type) {
                    return cc.sys.localStorage.getItem(name) || "";
                }
                return "";
            }


            public static NAME = "gameData";
        }
    }

    export var data: gameData.Main = null;
}